package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

public class activity_web extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web);

        // 接收传递过来的完整课程数据
        Intent intent = getIntent();
        String courseName = intent.getStringExtra("courseName");
        int courseCredit = intent.getIntExtra("courseCredit", 0);
        int maxNum = intent.getIntExtra("maxNum", 0);
        int selectedNum = intent.getIntExtra("selectedNum", 0);
        int courseImage = intent.getIntExtra("courseImage", R.drawable.spring);

        // 设置UI
        TextView courseTitle = findViewById(R.id.courseTitle);
        ImageView courseImageView = findViewById(R.id.courseImage);  // 重命名避免变量冲突
        TextView creditTextView = findViewById(R.id.creditTextView);
        TextView capacityTextView = findViewById(R.id.capacityTextView);  // 假设有这个控件

        // 更新UI数据
        courseTitle.setText(courseName);
        courseImageView.setImageResource(courseImage);
        creditTextView.setText("学分: " + courseCredit);
        capacityTextView.setText("可选人数: " + selectedNum + "/" + maxNum);  // 显示可选人数信息
    }
}